# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Olivier Biesmans <olivier at biesmans dot fr>

pkgbase=python-pyamf
pkgname=('python2-pyamf')  # 'python-pyamf' Python 3 version doesn't work so far
pkgver=0.8.0
pkgrel=4
pkgdesc="AMF support for Python"
arch=('loong64' 'x86_64')
url="https://github.com/hydralabs/pyamf"
license=('MIT')
makedepends=('python-setuptools' 'python2-setuptools' 'python-defusedxml' 'python2-defusedxml')
checkdepends=('python2-django' 'python2-sqlalchemy' 'python2-twisted' 'python2-lxml' 'python2-pillow')
source=("https://files.pythonhosted.org/packages/source/P/PyAMF/PyAMF-${pkgver}.tar.gz")
sha512sums=('1da66afbfb6cc32886a8680b5f610d17b3ad6e5cca338deb7f8d8c5e61f0f4e165b6602936590b4053a3bc98d0e36f898e5913e7d59d8444faf385fa036fd81e')

prepare() {
  cp -a PyAMF-$pkgver{,-py2}
}

build() {
  cd "$srcdir/PyAMF-$pkgver"
  # python setup.py build

  cd "$srcdir/PyAMF-$pkgver-py2"
  python2 setup.py build
}

check() {
  cd "$srcdir/PyAMF-$pkgver"
  # python setup.py test

  cd "$srcdir/PyAMF-$pkgver-py2"
  # Tests failed due to Django 1.8 https://github.com/hydralabs/pyamf/issues/53
  python2 setup.py test || warning "Tests failed"
}

package_python-pyamf() {
  depends=('python-defusedxml')

  cd "$srcdir/PyAMF-$pkgver"
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"
}

package_python2-pyamf() {
  depends=('python2-defusedxml')

  cd "$srcdir/PyAMF-$pkgver-py2"
  python2 setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"
}
